home *** CD-ROM | disk | FTP | other *** search
-
- {
- if(true)
- {
- CSoundChannel = §§newclass(CSoundChannel,EventDispatcher);
- }
- }
-
- package Local.Audio
- {
- import Local.*;
- import flash.display.*;
- import flash.events.*;
- import flash.filters.*;
- import flash.geom.*;
- import flash.media.*;
- import flash.utils.getTimer;
-
- public class CSoundChannel extends EventDispatcher
- {
-
- public static const CLOSING:String = "CLOSING";
-
- public static const mMixVolumeMax:Number = 1;
-
- public static const DISPOSING:String = "DISPOSING";
-
- public static const mDisturbTime:int = 1000 / 50;
-
-
- private var mSoundChannel:SoundChannel;
-
- public var mSounds:Object;
-
- private var mNewSound:Boolean;
-
- private var mResumeStartPosition:int;
-
- public var mPauseTimeStamp:uint;
-
- public var mDisposed:Boolean;
-
- public var _StartTimeStamp:uint;
-
- private var mSample:CSample;
-
- public function CSoundChannel()
- {
- super();
- mSounds = new Array();
- }
-
- public function set mStartTimeStamp(param1:uint) : void
- {
- var _loc2_:CSound = null;
- if(true)
- {
- _StartTimeStamp = param1;
- }
- for each(_loc2_ in mSounds)
- {
- _loc2_.mTimeStamp = _StartTimeStamp;
- }
- }
-
- public function RemoveSound(param1:CSound) : void
- {
- param1.removeEventListener(CSound.DISPOSING,e_SOUND_DISPOSING);
- mSounds.splice(mSounds.indexOf(param1),1);
- param1.Dispose();
- param1.mChannel = null;
- if(mSounds.length == 0)
- {
- Dispose();
- }
- }
-
- public function AddSound(param1:CSound) : void
- {
- if(true)
- {
- mSounds.push(param1);
- if(true)
- {
- if(!mSample)
- {
- if(true)
- {
- mSample = param1.mSample;
- addr31:
- mNewSound = true;
- }
- param1.mChannel = this;
- param1.addEventListener(CSound.DISPOSING,e_SOUND_DISPOSING);
- addr49:
- return;
- addr37:
- }
- §§goto(addr31);
- }
- §§goto(addr37);
- }
- §§goto(addr49);
- }
-
- public function get mStartTimeStamp() : uint
- {
- return _StartTimeStamp;
- }
-
- public function get mSampleID() : String
- {
- §§push(mSample);
- if(true)
- {
- return !!§§pop() ? mSample.mID : "none";
- }
- §§goto(addr14);
- }
-
- public function Start() : Boolean
- {
- mStartTimeStamp = getTimer();
- mNewSound = false;
- if(mSoundChannel = mSample.Start(mSoundTransform))
- {
- mSoundChannel.addEventListener(Event.SOUND_COMPLETE,e_SOUNDCOMPLETE);
- }
- §§push(mSoundChannel == null);
- if(true)
- {
- §§push(!§§pop());
- }
- return §§pop();
- }
-
- public function Pause() : void
- {
- var _loc1_:CSound = null;
- mResumeStartPosition = mSoundChannel.position;
- mPauseTimeStamp = getTimer();
- Stop();
- for each(_loc1_ in mSounds)
- {
- _loc1_.Pause();
- }
- }
-
- private function e_SOUND_DISPOSING(param1:Event = null) : void
- {
- var _loc2_:CSound = null;
- _loc2_ = CSound(param1.currentTarget);
- RemoveSound(_loc2_);
- }
-
- public function Resume() : void
- {
- var _loc1_:CSound = null;
- for each(_loc1_ in mSounds)
- {
- if(true)
- {
- _loc1_.Resume();
- }
- }
- if(true)
- {
- _StartTimeStamp += getTimer() - mPauseTimeStamp;
- if(true)
- {
- if(mSoundChannel = mSample.Start(mSoundTransform,mResumeStartPosition))
- {
- mSoundChannel.addEventListener(Event.SOUND_COMPLETE,e_SOUNDCOMPLETE);
- }
- }
- Update();
- }
- }
-
- private function get mSoundsUpdated() : Boolean
- {
- if(true)
- {
- return !mSample.mLooping && mNewSound;
- }
- §§goto(addr17);
- }
-
- public function Restart() : void
- {
- if(true)
- {
- Stop();
- Start();
- }
- }
-
- public function Update() : void
- {
- var _loc1_:CSound = null;
- for each(_loc1_ in mSounds.slice())
- {
- _loc1_.Update();
- }
- if(mDisposed)
- {
- return;
- }
- if(mSoundChannel)
- {
- if(mSoundChannel.position > mDisturbTime && mSoundsUpdated)
- {
- Restart();
- }
- else
- {
- mSoundChannel.soundTransform = mSoundTransform;
- }
- }
- else
- {
- Start();
- }
- }
-
- private function Stop() : void
- {
- if(mSoundChannel)
- {
- mSoundChannel.stop();
- mSoundChannel.removeEventListener(Event.SOUND_COMPLETE,e_SOUNDCOMPLETE);
- mSoundChannel = null;
- }
- }
-
- private function e_SOUNDCOMPLETE(param1:Event = null) : void
- {
- if(true)
- {
- dispatchEvent(new Event(CLOSING));
- Dispose();
- }
- }
-
- public function get mSoundTransform() : SoundTransform
- {
- var _loc1_:Number = NaN;
- var _loc2_:Number = NaN;
- var _loc3_:Number = NaN;
- var _loc4_:Number = NaN;
- var _loc5_:CSound = null;
- var _loc6_:SoundTransform = null;
- if(!CGlobal.mSoundActive)
- {
- return new SoundTransform(0,0);
- }
- _loc1_ = 0;
- _loc2_ = 0;
- _loc3_ = 0;
- _loc4_ = 0;
- for each(_loc5_ in mSounds)
- {
- if(true)
- {
- _loc3_ += _loc5_.mSoundTransform.leftToLeft;
- if(true)
- {
- _loc4_ += _loc5_.mSoundTransform.rightToRight;
- if(_loc5_.mSoundTransform.volume <= _loc2_)
- {
- continue;
- }
- }
- _loc2_ = _loc5_.mSoundTransform.volume;
- }
- }
- if(true)
- {
- (_loc6_ = !!mSoundChannel ? mSoundChannel.soundTransform : new SoundTransform()).volume = _loc2_;
- if(true)
- {
- _loc6_.leftToLeft = _loc3_ / mSounds.length;
- _loc6_.rightToRight = _loc4_ / mSounds.length;
- }
- return _loc6_;
- }
- §§goto(addr98);
- }
-
- public function Dispose() : void
- {
- var _loc1_:CSound = null;
- dispatchEvent(new Event(DISPOSING));
- Stop();
- for each(_loc1_ in mSounds)
- {
- _loc1_.mChannel = null;
- }
- if(true)
- {
- mDisposed = true;
- }
- }
- }
- }
-